# -*- coding: utf-8 -*-
import os
import sys
from testsuites.suite_demo import suite
from XTestRunner import HTMLTestRunner
from utils.email_util import EmailUtils


if __name__ == '__main__':

    # 生成测试报告
    filename = 'reports/result.html'
    try:
        with open(filename, 'wb+') as f:
            runner = HTMLTestRunner(
                stream=f,
                title='测试报告',
                description='互帮互助自动化测试',
                tester='报告'
            )
            runner.run(suite)

        # 发送邮件
        email = EmailUtils(
            user='2978275192@qq.com',
            password='bffbpbezmajrdgij',
            host='smtp.qq.com'
        )
        email.send_email(
            log_file_name=filename
        )

    except Exception as e:
        print(f"执行出错: {str(e)}")
        sys.exit(1)
